<template>
  <div>
    <el-card>
      <el-form :inline="true" class="demo-form-inline">
        <el-form-item :label="$t('充值人员')">
          <el-input disabled v-model="formInline.userId" :placeholder="$t('充值人员')"></el-input>
        </el-form-item>
        <el-form-item :label="$t('充值金额')">
          <el-input v-model="formInline.amountFlow" :placeholder="$t('充值金额')"></el-input>
        </el-form-item>
        <el-form-item :label="$t('充值备注')">
          <el-input v-model="formInline.note" :placeholder="$t('充值备注')"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">{{ $t('充值') }}</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>
<script>
import { getusertopupApi } from "../../../api/appuser/userList";
export default {
  data() {
    return {
      formInline: {
        userId: this.$route.query.userId,
        amountFlow: "",
        note: "",
      },
    };
  },
  created() {
    if (!this.$route.query.userId) {
      this.$message.error(this.$t("请先到用户列表选择对应用户"));
      this.$router.push("/system/userList");
      return;
    }
  },
  methods: {
    async onSubmit() {
      if (this.formInline.amountFlow < 0) {
        return this.$message.error("金额不能为负数");
      }
      await getusertopupApi(this.formInline);
      this.$message.success("充值成功");
      this.formInline = {};
    },
  },
};
</script>
<style lang='' scoped>
</style>
